package com.k12.user.controller;

import com.k12.user.model.entity.SysAreaCities;
import com.k12.user.service.SysAreaCitiesService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 城市代码库(SysAreaCities)表控制层
 *
 * @author makejava
 * @since 2025-07-28 20:53:10
 */
@RestController
@RequestMapping
public class SysAreaCitiesController {
    /**
     * 服务对象
     */
    @Resource
    private SysAreaCitiesService sysAreaCitiesService;

    /**
     * 分页查询
     *
     * @param sysAreaCities 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @GetMapping("getAllCity")
    public List<SysAreaCities> queryByPage(SysAreaCities sysAreaCities) {
        return this.sysAreaCitiesService.queryByPage(sysAreaCities);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("getOneCity/{id}")
    public SysAreaCities queryById(@PathVariable("id") Integer id) {
        return this.sysAreaCitiesService.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param sysAreaCities 实体
     * @return 新增结果
     */
    @PostMapping("insertCity")
    public SysAreaCities add(SysAreaCities sysAreaCities) {
        return this.sysAreaCitiesService.insert(sysAreaCities);
    }

    /**
     * 编辑数据
     *
     * @param sysAreaCities 实体
     * @return 编辑结果
     */
    @PutMapping("updateCity")
    public SysAreaCities edit(SysAreaCities sysAreaCities) {
        return this.sysAreaCitiesService.update(sysAreaCities);
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping("deleteCity")
    public Boolean deleteById(Integer id) {
        return this.sysAreaCitiesService.deleteById(id);
    }

}

